﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Text.RegularExpressions;

/*
using System.Resources;
using System.Reflection;
using System.Threading;
using System.Globalization;
*/

namespace InsuranceCompany.Helpers
{
    public static class FieldsValidation
    {
        private static string MessageText;

        private static bool Valid = true;

        private static bool EmailValid = true;
        public static string CheckEmail(string email)
        {
            //ResourceManager rm = new ResourceManager("InsuranceCompany", Assembly.GetExecutingAssembly());
            MessageText = "";
            bool isValid = Regex.IsMatch(email,
              @"^(?("")("".+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))" +
              @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$");
            /*
            if (!isValid)
            {
                MessageText = "Ввдедите корректный email.";
                Valid = false;
                EmailValid = false;
                MessageBox.Show(MessageText);
            } else
                EmailValid = true; 
            */
            return email;
        }

        public static bool IsValid() 
        {
            Valid = EmailValid;
            return Valid; 
        }
        public static string GetMessageText() { return MessageText; }
    }
}
